#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>

using namespace std;

#include"string.h"


void test_string1()
{
	const char s[] = "hello world";
	char ss = *s;
	char* s1 = nullptr;
	cout << ss;
}

void test_string2()
{
	yj::string ss1 = "hello world";

	for (int i = 0; i < ss1.size();i++)
	{		
		cout << ss1[i] << "|";
	}
	cout << endl;

	yj::string::iterator it = ss1.begin();
	while (it != ss1.end())
	{
		cout << *it << '|';
		++it;
	}
	cout << endl;

	for (auto c : ss1)
	{
		cout << c << '|';
	}
	cout << endl;
}

void test_string3()
{
	string s = "hello";
	for (char c : s)
	{
		cout << c << "|";
	}
}

void test_string4()
{
	yj::string  ss = "hellow world";
	cout << ss.c_str() << endl;

	ss.push_back(' ');
	ss.append("ni hao zhong guo");
	cout << ss.c_str() << endl;

	ss += '@';
	ss += "ni hao";
	cout << ss.c_str() << endl;

	ss += "s";
	cout << ss.c_str() << endl;
}

void test_string5()
{
	yj::string  ss = "hello world";
	cout << ss.c_str() << endl;

	ss.insert(11, '!');
	ss.insert(0, '!');

	//cout << ss.c_str() << endl;
	cout << ss << endl;

	//cin >> ss;
	//cout << ss;

	ss.insert(6, " xxx");
	ss.insert(0, " xxx ");
	cout << ss << endl;

	ss.erase(0, 5);
	cout << ss << endl;

	ss.erase(6, 4);
	cout << ss << endl;

	ss.erase(12,1);
	cout << ss << endl;
}

void test_string6()
{
	yj::string  ss = "hello world";
	cout << ss.c_str() << endl;

	cout << ss.find('h')<<endl;
	cout << ss.find("world") << endl;

	yj::string s = ss.substr(6, 99);
	cout<<s.find('o')<<endl;
	cout << s << endl;


	s += " hello ";
	s.resize(13,'x');
	cout << s << endl;
}

void test_string7()
{
	string s = "hello world";
	cout << s << endl;
	string ss=s.substr(6, 10);
	cout << ss << endl;

	//cout << s.find('w') << endl;

	ss.resize(1,'x');
	cout << ss << endl;
}

void func1(string s)
{
	string ss = s;
	cout << ss << endl;
}
void test_string8()
{
	string s1 = "hello world";
	func1(s1);

	//cin >> s1;
	//cout << s1;

	//char* array = nullptr;
	//cout << sizeof(array) << endl;
}

int main()
{
	test_string7();
	return 0;
}